﻿#include<iostream>
using namespace std;
double calculateArea(string form = "circle", double dimension1 = 1.0, double dimension2 = 1.0, double dimension3 = 1.0) {
	if (form == "circle") {
		return 3.1415926 * dimension1 * dimension1;
	}
	else if (form == "rectangle") {
		return dimension1 * dimension2;
	}
	else if (form == "triangle") {
		double s = (dimension1 + dimension2 + dimension3) / 2;
		return sqrt(s * (s - dimension1) * (s - dimension2) * (s - dimension3));
	}
	return 0.0;
}
int main() {
	cout << "请输入要计算的图形类型(1-圆形，2-矩形，3-三角形): ";
	int choice = 0;
	cin >> choice;
	double r = 1.0;
	double l = 2.0, w = 2.0;
	double length[3] = { 3.0 };
	cout << "请输入";
	switch (choice)
	{
	case 1:
		cout << "圆形的半径：";
		cin >> r;
		cout << "该图形为圆形，其面积为：" << calculateArea("circle", r, r, r);
		break;
	case 2:
		cout << "矩形的长和宽： ";
		cin >> l >> w;
		cout << "该图形为矩形，其面积为：" << calculateArea("rectangle", l, w, r);
		break;
	case 3:
		cout << "三角形的边长： ";
		for (int i = 0; i < 3; i++) {
			cin >> length[i];
		}
		cout << "该图形为三角形，其面积为：" << calculateArea("triangle", length[0], length[1], length[2]);
		break;
	default:
		break;
	}
}